package yagwl.client.model;

import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;

/**
 * TODO java doc
 */
public class TreeNodeEvent extends GwtEvent<TreeNodeEvent.TreeNodeEventHandler> {

  public static final Type<TreeNodeEventHandler> TYPE = new Type<TreeNodeEventHandler>();

  private String treeCacheClassName;
  private TreeNodeAction treeNodeAction;
  private TreeNodeDTO treeNode;

  TreeNodeEvent(String treeCacheClassName, TreeNodeAction treeNodeAction,
      TreeNodeDTO treeNode) {
    super();
    this.treeCacheClassName = treeCacheClassName;
    this.treeNodeAction = treeNodeAction;
    this.treeNode = treeNode;
  }

  public String getTreeCacheClassName() {
    return treeCacheClassName;
  }

  public TreeNodeAction getTreeNodeAction() {
    return treeNodeAction;
  }

  public TreeNodeDTO getTreeNode() {
    return treeNode;
  }

  @Override
  protected void dispatch(TreeNodeEventHandler handler) {
    handler.onTreeNodeEvent(this);
  }

  @Override
  public GwtEvent.Type<TreeNodeEventHandler> getAssociatedType() {
    return TYPE;
  }

  public enum TreeNodeAction {
    Create, Delete, Update, UpdateLabel, AddItem, RemoveItem
  };

  public interface TreeNodeEventHandler extends EventHandler {
    public void onTreeNodeEvent(TreeNodeEvent event);
  }

}
